import { Component, OnInit } from '@angular/core';
import { User } from 'src/app/domain/user';

import { AuthService } from '../../service/auth.service';

import { ManagerService } from '../../service/manager.service';
/*

@Author:李朝晖

@Date: 2018-12-12

@经理侧边栏功能实现

@Last Modified time: 2018-12-16
*/
@Component({
  selector: 'app-manager-navbar',
  templateUrl: './manager-navbar.component.html',
  styleUrls: ['./manager-navbar.component.css']
})
export class ManagerNavbarComponent implements OnInit {

  private manager: User;
  constructor(private managerService: ManagerService) {
    this.manager = {
      id: null,
      user_name: null,
      name: null,
      age: null,
      sex: null,
      department: null, //部门
      position: null, //职务
      annual_leave_length: null, //年假上限
      remain_annual_leave: null, //剩余年假
    };
  }

  ngOnInit() {
    this.getUser();
  }

  getUser(){
    var id = AuthService.getUserId();
    if(id == 0){
      alert("请先登录");
    }else{
      this.managerService.getUser(id)
      .subscribe(manager => {this.manager = manager[0];console.log("dsdsad");});
    }

  }

}
